package control

import (
	ofst "git.oschina.net/ant180/util/statistic"
)

const (
	_          = iota
	SCAN_A_MSG = iota
	SCAN_B_MSG
	SCAN_C_MSG
	SCAN_H_MSG
	SCAN_ALL_SUCC

	SCAN_MAX_NUM
)

//
type Statistics struct {
	counts []int64
}

func NewStatistics() *Statistics {
	return &Statistics{
		counts: make([]int64, SCAN_MAX_NUM, SCAN_MAX_NUM),
	}
}

func (p *Statistics) Add(ptype int, delta int64) {
	if ptype >= SCAN_MAX_NUM {
		return
	}
	p.counts[ptype] += delta
}

func (p *Statistics) Get(ptype int) int64 {
	if ptype >= SCAN_MAX_NUM {
		return -1
	}
	return p.counts[ptype]
}

const (
	StatHTTPListSucc = ofst.StatType(0)
	StatHTTPListFail = ofst.StatType(1)
	StatHTTPZSetSucc = ofst.StatType(2)
	StatHTTPZSetFail = ofst.StatType(3)

	StatHTTPSListSucc = ofst.StatType(4)
	StatHTTPSListFail = ofst.StatType(5)
	StatHTTPSZSetSucc = ofst.StatType(6)
	StatHTTPSZSetFail = ofst.StatType(7)

	StatMax = ofst.StatType(8)
)

var StatStrs []string = []string{
	"type=http,redis=list,action=succ",
	"type=http,redis=list,action=fail",
	"type=http,redis=zset,action=succ",
	"type=http,redis=zset,action=fail",

	"type=https,redis=list,action=succ",
	"type=https,redis=list,action=fail",
	"type=https,redis=zset,action=succ",
	"type=https,redis=zset,action=fail",
}
